<template>
    <div class="refund">
        <el-form :inline="true" :model="formInline">
            <el-date-picker
                v-model="dateValue"
                type="daterange"
                change="changTime"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd">
            </el-date-picker>
        <el-form-item>
            <el-button type="primary" @click="search">搜索</el-button>
            <el-button type="primary" @click="reset">重置</el-button>
        </el-form-item>
        </el-form>
        <el-table
            :header-cell-style="{color:'#555555'}"
            class="black"
            :data="tableData"
            stripe
            border
            style="width: 100%">
            <el-table-column
                prop="date"
                label="日期"
                align="center">
            </el-table-column>
            <el-table-column
                prop="redPacket"
                label="红包照片"
                align="center">
            </el-table-column>
            <el-table-column
                prop="contactWay"
                label="查看联系方式"
                align="center">
            </el-table-column>
            <el-table-column
                prop="broadCast"
                label="约会广播"
                align="center">
            </el-table-column>
            <el-table-column
                prop="member"
                label="会员"
                align="center">
            </el-table-column>
            <el-table-column
                prop="memberCount"
                label="会员人次"
                align="center">
            </el-table-column>
            <el-table-column
                prop="album"
                label="付费查看"
                align="center">
            </el-table-column>
            <el-table-column
                prop="albumCount"
                label="付费查看人次"
                align="center">
            </el-table-column>
            <el-table-column
                prop="totalAmount"
                label="总收入"
                align="center">
            </el-table-column>
            <el-table-column
                prop="sum_profit"
                label="总利润"
                align="center">
            </el-table-column>
            <el-table-column label="操作" align="center" width="120">
                <template slot-scope="scope">
                    <el-button @click="onDetailClick(scope.row)" size="small">查看明细</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="footer-page">
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="page"
                :page-sizes="[10, 20, 50, 100]"
                :page-size="page_size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total_page">
            </el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    name: 'withdraw-hadle',
    data () {
        return {
            dateValue: '',
            params: {
                startDate: '',
                endDate: '',
                page: 1,
                size: 20
            },
            page: 1,
            page_size: 20,
            total_page: 0,
            formInline: {
                station_id: '',
                station_name: '',
                station_state: ''
            },
            tableData: [{
                id: '30212078', // 站点ID
                date: '20181101', // 创建时间
                redPacket: '120元', // 站点名称
                contactWay: '120元', // 结果状态
                broadCast: '120元', // 状态更新时间
                deposit: '120元', // 订金
                member: '200元', // 会员收入
                member_number: '10', // 会员人次
                album: '130元', // 付费查看
                pay_number: '180', // 查看人次
                totalAmount: '150元', // 总收入
                sum_profit: '100元' // 总利润
            } ]
        }
    },
    created () {
        // this.tableData = []
    },
    mounted () {
        // 进来页面获取课程
        this.getList(this.params)
    },
    methods: {
        search () {
            this.page = 1
            this.params = {
                startDate: this.dateValue[0],
                endDate: this.dateValue[1],
                page: this.page,
                size: this.page_size
            }
            // 进来页面获取课程
            this.getList(this.params)
        },
        reset () {
            this.formInline = {
                dateValue: ''
            }
        },
        onDetailClick (row) {
            this.$router.push({
                name: 'system.detail',
                params: {
                    date: row.date
                }
            })
        },
        handleSizeChange (val) {
            this.page_size = val
            this.params.size = val
            this.getList(this.params)
        },
        handleCurrentChange (val) {
            this.page = val
            this.params.page = val
            this.getList(this.params)
        },
        getList (params) {
            let data = {
                'params': params
            }
            this.tableData = []
            this.$api.system.getIncomeList(data, res => {
                // 隐藏加载动画
                // this.$vux.loading.hide()
                if (res.code === 200) {
                    let list = res.data.list
                    for (let i = 0; i < list.length; i++) {
                        this.tableData.push(list[i])
                    }
                    this.total_page = res.data.totalCount
                    this.page = res.data.currPage
                    this.page_size = res.data.pageSize
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
    .refund {
        position: relative;
        width: 100%;
        height: 100%;
        .margin-bottom-12 {
            margin-bottom: 10px;
        }
        .el-row {
            margin-bottom: 20px;
            &:last-child {
                margin-bottom: 0;
            }
        }
        .el-col {
            border-radius: 4px;
        }
        .grid-content {
            position: relative;
            height: 40px;
        }
        .grid-padding {
            /* padding-left: 20px; */
            padding-right: 20px;
        }
        .grid-title {
            float: left;
            width: 72px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .grid-input {
            float: left;
            width: 130px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .row-bg {
            padding: 10px 0;
            background-color: #f9fafc;
        }
        .footer-page {
            width: 540px;
            margin: 0 auto;
            padding-top: 20px;
        }
    }
</style>
